package com.yeung;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;

import java.util.Locale;

/**
 * @SpringBootApplication 标注一个主程序
 * <p>
 * 注意:!!!
 * SpringBootApplication 默认只扫描当前包及其所有子包扫描注册到ioc容器中
 * <p>
 * 不在同意包内的组件扫描不到
 */
//@ImportResource(locations = {"classpath:beans.xml"})
@SpringBootApplication
@MapperScan(basePackages = {"com.yeung.dao.mapper"})//如果mapper过多 这可以指定扫描 某个包下的所有mapper,而不用再每个类上田间@mapper注解
public class Application {
    public static void main(String[] args) {
//        也可以通过命令参数指定激活的配置文件
//        --spring.profiles.active=dev   作为应用程序运行时的参数
        //启动springboot应用

        SpringApplication.run(Application.class, args);
    }

    @Bean
    public ViewResolver myViewResolver() {
        return new MyViewResolver();
    }

    private static class MyViewResolver implements ViewResolver {

        @Override
        public View resolveViewName(String s, Locale locale) {
            return null;
        }
    }
}
